package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletResponseAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zr.service.SearchUidService;

import net.sf.json.JSONArray;

@Controller
@Scope(value="prototype")
public class SearchUid implements ServletResponseAware{
	
	private HttpServletResponse resp;
	
	@Resource 
	private SearchUidService searchuid;
	
	public void searchuid(){
		JSONArray j = searchuid.finduid();
		PrintWriter pw;
		try {
			pw = resp.getWriter();
			pw.write(j.toString());
			pw.flush();
			pw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
	public void searchuids(){
		JSONArray j = searchuid.finduids();
		PrintWriter pw;
		try {
			pw = resp.getWriter();
			pw.write(j.toString());
			pw.flush();
			pw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	@Override
	public void setServletResponse(HttpServletResponse resp) {
		this.resp=resp;
	}
	
}
